home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_weap_tokarev.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  215 lines

  1. # Jones 3D Cog Script
  2. #
  3. # weap_Tokarev.cog
  4. #
  5. # This COG controls the Tokarev Automatic Pistol.
  6. #
  7. # [RandyT]
  8. #
  9. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  10. #
  11. # ===================================================================
  12.  
  13. symbols
  14.  
  15. message        startup
  16. message        fire
  17. message        aim
  18. message        activated
  19. message        deactivated
  20. message        selected
  21. message        deselected
  22. message        callback
  23.  
  24. sound        bang=gen_tokarev_fire.wav    local    # Autoloaded
  25. sound        pull=gen_pistol_pull.wav    local    # Autoloaded
  26. sound        put=gen_pistol_put.wav        local    # Autoloaded
  27.  
  28. template    projectile=+tokarev            local    # Autoloaded
  29. template    smoke1=+pistol_smoke1        local    # Autoloaded
  30. template    smoke2=+pistol_smoke2        local    # Autoloaded
  31.  
  32. thing        player                        local
  33. thing        bullet                        local
  34.  
  35. flex        aimFOV=10.0                    local
  36. flex        aimMax=90.0                    local
  37. flex        aimWait=0.25                local
  38. flex        fireWait=0.52                local
  39.  
  40. int            handNode                    local
  41. int            holsterMesh                    local
  42. int            weaponNum=4                    local
  43. int            callNum                        local
  44.  
  45. int            bJacketIndy=0                local
  46. int            bActivated=0                local
  47.  
  48. vector        firePos                        local
  49.  
  50. end
  51.  
  52. # ===================================================================
  53.  
  54. code
  55.  
  56. startup:
  57.  
  58.     player = GetLocalPlayerThing();
  59.     handNode = GetNodeByName(player, "inrhand");
  60.  
  61.     bJacketIndy = IsThingModelName(player, "gen_in.3do");
  62.  
  63.     if (!bJacketIndy)
  64.     {
  65.         holsterMesh = GetMeshByName(player, "inholster");
  66.         LoadHolsterModel(weaponNum, "holster_in_tokarev.3do");
  67.  
  68.         if (GetLastPistol(player) == weaponNum)
  69.         {
  70.             SetHolsterModel(player, weaponNum, holsterMesh);
  71.         }
  72.     }
  73.  
  74.     return;
  75.  
  76. # -------------------------------------------------------------------
  77.  
  78. fire:
  79.  
  80.     # Make sure Indy's not out of ammo
  81.     if (GetInv(player, weaponNum) < 1)
  82.     {
  83.         PlayVoiceMode(player, 123);
  84.         SelectWeapon(player, 3);
  85.         return;
  86.     }
  87.  
  88.     # Fire away...
  89.     firePos = GetThingJointPos(player, handNode);
  90.     bullet = FireProjectile(player, projectile, bang, 65, firePos, '3.0 -6.5 0.0', 1.0, 0x2a0, aimFOV, aimMax);
  91.  
  92.     if (Rand() < 0.5) CreateThing(smoke1, bullet);
  93.     else CreateThing(smoke2, bullet);
  94.  
  95.     ChangeInv(player, weaponNum, -1.0);
  96.     SetFireWait(player, fireWait);
  97.  
  98.     return;
  99.  
  100. # -------------------------------------------------------------------
  101.  
  102. aim:
  103.  
  104.     if (GetParam(0))
  105.     {
  106.         if (!IsAiming(player) && !bActivated)
  107.         {
  108.             while ((PlayMode(player, 63, 0) == -99) && (!bActivated))
  109.             {
  110.                 Sleep(0.01);
  111.             }
  112.         }
  113.     }
  114.     else if (IsModePlaying(player, 63) && !bActivated)
  115.     {
  116.         SetAimWait(player, aimWait);
  117.         StopMode(player, 63, aimWait);
  118.     }
  119.  
  120.     return;
  121.  
  122. # -------------------------------------------------------------------
  123.  
  124. activated:
  125.  
  126.     bActivated = 1;
  127.     SetAimWait(player, aimWait);
  128.  
  129.     if (!IsAiming(player))
  130.     {
  131.         while (PlayMode(player, 63, 0) == -99)
  132.         {
  133.             Sleep(0.01);
  134.         }
  135.     }
  136.  
  137.     ActivateWeapon(player, aimWait);
  138.  
  139.     return;
  140.  
  141. # -------------------------------------------------------------------
  142.  
  143. deactivated:
  144.  
  145.     bActivated = 0;
  146.  
  147.     if (!IsAiming(player))
  148.     {
  149.         SetAimWait(player, aimWait);
  150.         StopMode(player, 63, aimWait);
  151.     }
  152.  
  153.     DeactivateWeapon(player);
  154.  
  155.     return;
  156.  
  157. # -------------------------------------------------------------------
  158.  
  159. selected:
  160.  
  161.     SetMountWait(player, 0.7);
  162.  
  163.     SetArmedMode(player, 2);
  164.     SetCurWeapon(player, weaponNum);
  165.     SetThingFireOffset(player, '0.06 0.015 0.002');
  166.  
  167.     CaptureThing(player);
  168.     PlayMode(player, 62, 0);
  169.  
  170.     return;
  171.  
  172. # -------------------------------------------------------------------
  173.  
  174. deselected:
  175.  
  176.     if (IsAiming(player))
  177.     {
  178.         SetAimWait(player, aimWait);
  179.         StopMode(player, 63, aimWait);
  180.     }
  181.  
  182.     SetMountWait(player, 1.07);
  183.  
  184.     StopMode(player, 62, 0);
  185.  
  186.     CaptureThing(player);
  187.     PlayMode(player, 64, 0);
  188.  
  189.     SetArmedMode(player, 0);
  190.  
  191.     return;
  192.  
  193. # -------------------------------------------------------------------
  194.  
  195. callback:
  196.  
  197.     callNum = GetParam(1);
  198.     ReleaseThing(player);
  199.  
  200.     if (callNum == 28)
  201.     {
  202.         if (!bJacketIndy) ResetHolsterModel(player, 2);
  203.         PlaySoundThing(pull, player, 1, -1, -1, 0x880);
  204.         SetWeaponModel(player, weaponNum);
  205.     }
  206.     else if (callNum == 29)
  207.     {
  208.         if (!bJacketIndy) SetHolsterModel(player, weaponNum, holsterMesh);
  209.         PlaySoundThing(put, player, 1, -1, -1, 0x880);
  210.         ResetWeaponModel(player);
  211.     }
  212.  
  213.     return;
  214.  
  215. end